// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
  return cloud.callFunction({
    name: "model_ticket",
    data: {
      op: "add",
      ticket_number: event.ticket_number,
      g_id: event.good_id,
      s_id: event.student_id,
      status: event.status,
      express: event.express,
      express_number: event.express_number,
      detail: event.detail,
      u_id: event.user_id,
      i_id: event.institution_id
    }
  }).then(res => {
    return cloud.callFunction({
      name: "model_ticket",
      data: {
        op: "select",
        key: "_id",
        value: res.result._id
      }
    }).then(res => { return res.result.data; })
  })
}